<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="assets/swiper-5.4.5/package/css/swiper.css">
  <link rel="stylesheet" href="assets/swiper-5.4.5/src/animate.min.css">
  <link rel="stylesheet" href="assets/css/test.css">
  <script src="assets/bootstrap4/js/jquery-3.1.1.js"></script>
  <script src="assets/swiper-5.4.5/package/js/swiper.js"></script>
  <script src="assets/swiper-5.4.5/src/swiper.animate.min.js"></script>
</head>
<body>
<div class="section-bottom">
  <div class="swiper-container">
    <p class="swiper-line"></p>
    <p class="swiper-name">
      <span>珊瑚橙<br>绮境森林<br>仲夏紫<br>亮黑色</span>
    </p>
    <p class="swiper-num">
      <span>01<br>02<br>03<br>04</span>
    </p>
    <div class="swiper-wrapper">
      <div class="swiper-slide">
        <img src="assets/images/orange_left.png"
             class="ani"
             swiper-animate-effect="mySlideInUp">
        <img src="assets/images/orange_right.png"
             class="ani"
             swiper-animate-effect="mySlideInUp"
             swiper-animate-delay="0.1s">
      </div>
      <div class="swiper-slide">
        <img src="assets/images/green_left.png"
             class="ani"
             swiper-animate-effect="mySlideInDown">
        <img src="assets/images/green_right.png"
             class="ani"
             swiper-animate-effect="mySlideInUp"
             swiper-animate-delay="0.1s">
      </div>
      <div class="swiper-slide">
        <img src="assets/images/purple_left.png"
             class="ani"
             swiper-animate-effect="mySlideInUp">
        <img src="assets/images/purple_right.png"
             class="ani"
             swiper-animate-effect="mySlideInUp"
             swiper-animate-delay="0.1s">
      </div>
      <div class="swiper-slide">
        <img src="assets/images/black_left.png"
             class="ani"
             swiper-animate-effect="mySlideInUp">
        <img src="assets/images/black_right.png"
             class="ani"
             swiper-animate-effect="mySlideInUp"
             swiper-animate-delay="0.1s">
      </div>
    </div>
    <!-- 如果需要分页器 -->
    <div class="swiper-pagination"></div>
  </div>
</div>
<script>
  let mySwiper = new Swiper ('.swiper-container', {
    // 开启自动轮播
    // autoplay: true,//等同于以下设置
    autoplay: {
      delay: 3000,
      stopOnLastSlide: false,
      // 点击后是否停止自动轮播
      disableOnInteraction: false
    },
    // 开启分页器
    pagination: {
      // 装载分页器元素的盒子
      el: '.swiper-pagination',
      // 修改每个分页项的类名
      bulletClass : 'my-bullet',
      // 修改分页选中项的类名
      bulletActiveClass: 'my-bullet-active',
      clickable: true
    },
    on: {
      init() {
        swiperAnimateCache(this); //隐藏动画元素
        swiperAnimate(this); //初始化完成开始动画
      },
      // swiper从一个slide过渡到另一个slide结束时执行
      slideChangeTransitionEnd: function(){
        // 切换之后回来还能执行动画
        swiperAnimate(this);
        console.log(this.activeIndex);
        $(".swiper-name>span").eq(0).animate({
          top: -this.activeIndex * 45 + 'px'
        }, 1000)
        $(".swiper-num>span").eq(0).animate({
          top: -this.activeIndex * 45 + 'px'
        }, 1000)
      }
    }
  })
</script>
</body>
</html>
